<!--
  -    Copyright (c) 2018-2025, seefa All rights reserved.
  -
  - Redistribution and use in source and binary forms, with or without
  - modification, are permitted provided that the following conditions are met:
  -
  - Redistributions of source code must retain the above copyright notice,
  - this list of conditions and the following disclaimer.
  - Redistributions in binary form must reproduce the above copyright
  - notice, this list of conditions and the following disclaimer in the
  - documentation and/or other materials provided with the distribution.
  - Neither the name of the pig4cloud.com developer nor the names of its
  - contributors may be used to endorse or promote products derived from
  - this software without specific prior written permission.
  - Author: seefa
  -->

<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        ref="crud"
        :page="page"
        :data="tableData"
        :table-loading="tableLoading"
        :option="tableOption"
        @search-change="searchChange"
        @size-change="sizeChange"
        @current-change="currentChange"
        @search-reset="searchReset"
         @refresh-change="refreshChange"
        @on-load="getList"
      ></avue-crud>
    </basic-container>
  </div>
</template>

<script>
import { Interrogate } from "@/api/list/index";
import { tableOption } from "@/const/crud/list/index";

export default {
  name: "list",
  data() {
    return {
      searchForm: {},
      form: {},
      tableData: [],
      tableDictItemData: [],
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 20 // 每页显示多少条
      },
      tableLoading: false,
      tableOption: tableOption
    };
  },

  methods: {
    getList(page, params) {
      this.tableLoading = true;
      Interrogate(
        Object.assign(
          {
            pageNum: page.currentPage,
            pageSize: page.pageSize,
            countSql: true
          },
          params,
          this.searchForm
        )
      ).then(response => {
        this.tableData = response.data.data.list;
        this.page.total = response.data.data.total;
        this.tableLoading = false;
      });
    },

    handleSave: function(row, done) {
      addObj(row).then(() => {
        this.$message.success("添加成功");
        this.getList(this.page);
        done();
      });
    },
    searchChange(form, done) {
      this.searchForm = form;
      this.getList(this.page, form);
      done();
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    currentChange(current) {
      this.page.currentPage = current;
    },
    searchReset() {
      this.searchForm = {};
      this.getList(this.page);
    },
        refreshChange() {
        this.getList(this.page)
      }
  }
};
</script>

<style lang="scss" scoped>
</style>

